﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataAccessLayer;
using System.Data;

namespace BussinessLogicLayer
{
    public class BLL_Course
    {
        public static List<COURSE> LoadAll()
        {
            var listCourse = new List<COURSE>();
            DataTable dt = DAO_Course.LoadAll();
            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataRow row in dt.Rows)
                {
                    listCourse.Add(new COURSE
                    {
                        COURSE_ID = row["COURSE_ID"].ToString(),
                        COURSE_NAME = row["COURSE_NAME"].ToString().Trim()
                    });
                }
            }

            return listCourse;
        }

        public static COURSE Get(string courseID)
        {
            var course = new COURSE();
            DataTable dt = DAO_Course.Get(courseID);
            if (dt != null && dt.Rows.Count > 0)
            {
                course.COURSE_ID = dt.Rows[0]["COURSE_ID"].ToString();
                course.COURSE_NAME = dt.Rows[0]["COURSE_NAME"].ToString().Trim();
            }

            return course;
        }
    }
}
